#ifndef __LSST__
#define __LSST__

#include <string>
#include <vector>
#include <armadillo>

#include <imcmc/imcmc.hpp>

#include "math_libs.hpp"

using namespace imcmc;

//  ===================================================================================
//  structure "LSST_Forecast_WB" contains forecasted Fisher matrix provided by Hu Zhan.
//  
//  ===================================================================================

struct LSST_Forecast_WB{

    DataInfo data_info;
    
    std::string FMatrixFile;
    arma::mat   FisherMatrix;
    arma::vec   Params_fid;

    LSST_Forecast_WB();
    ~LSST_Forecast_WB();

    void Init( std::string& lsst_wb_dataset, bool& use_WL, bool& use_BAO );
};

//  ============================================================================
//  LSST SNeIa's redshifts are measured photometrically, there will be extrac
//  constributions to the total errors in the distance modulus.  Besides, theoretically
//  one should take into account the uncertainties in the redshifts.
struct SNeIa_LSST{

    DataInfo data_info;

    int sn_num;
    double *sn_z;
    double *sn_mu;
    double *sn_err;
    double *sn_zerr;
    double photo_z_err;

    SNeIa_LSST();
    ~SNeIa_LSST();

    gsl_interp_accel *acc_ns;
    gsl_spline *spline_ns;

    arma::mat A;   // 100 x 200
    int A_nrow, A_ncol;
    double zs_min, zs_max;
    double zp_min, zp_max;
    double *zs,*zp;
    void init_matrix_A( std::string& lsst_sn_dataset );
    double zp_current;

    double muzperr_zmin, muzperr_zmax;
    double *muzperr_z, *muzperr;
    gsl_interp_accel *acc_muzperr;
    gsl_spline *spline_muzperr;

//  interface for DataList and Likelihoods
    void Init( std::string& lsst_sn_dataset );
};

double photoz_mu_integrand( double z, void *param );

//  ====================================
//  prototypes of likelihood functions


double Likelihood_LSST_WB(  imcmc_double&   full_params,
                            double&         lndet,
                            double&         chisq,
                            void*           model,
                            void*           data,
                            istate&         state );

double Likelihood_LSST_SNe( imcmc_double&   full_params,
                            double&         lndet,
                            double&         chisq,
                            void*           model,
                            void*           data,
                            istate&         state );

//  ====================================
//  define new names for convenience
//  ====================================
typedef LSST_Forecast_WB LSST_WB;
typedef SNeIa_LSST LSST_SNe;

#endif // __LSST__
